﻿using System;
using System.Configuration;
using System.Data.SqlClient;

namespace MayhemServer.Services {
    public static class DatabaseService {
        private const string ConnectionStringKey = "Default";

        // Not ideal, but given time constraints will have to do for now
        public static SqlConnection GetConnection() {
            var connectionString = ConfigurationManager.ConnectionStrings[ConnectionStringKey];
            if (connectionString == null) {
                throw new Exception(string.Format("Connection string named '{0}' could not be found", ConnectionStringKey));
            }
            return new SqlConnection(connectionString.ConnectionString);
        }
    }
}